<template>
  <Modal
    v-model="show"
    title="批量设置运费(仅设置当前搜索条件下商品)"
    @on-ok="onOk"
    @on-cancel="cancel"
  >
    <Select v-model="freightTemplateId" @on-select="onfreightChange">
      <Option v-for="item in list" :key="item.id" :value="item.id">{{ item.name }}</Option>
    </Select>
  </Modal>
</template>

<script>
import { clearEmpty } from '@/util'
export default {
  props: {
    list: {
      type: Array,
      default: () => []
    }
  },
  data () {
    return {
      show: false,
      freightTemplateId: null,
      param: {}
    }
  },
  methods: {
    open (param) {
      this.param = param
      this.freightTemplateId = null
      this.show = !this.show
    },
    onfreightChange (data) {
      this.param.freightTemplateId = data.value
    },
    onOk () {
      const param = clearEmpty(this.param)
      this.$jsonPost('/product/business/update/freight/batch', param).then(res => {
        this.$Notice.success({
          title: '批量修改成功'
        })
        this.$emit('complete')
      })
    }
  }
}
</script>

<style>

</style>
